//
//  UIView+TransitioningUtils.m
//  TransitioningDelegateManager
//
//  Created by Apple on 2018/3/21.
//  Copyright © 2018年 LYKM. All rights reserved.
//

#import "UIView+TransitioningUtils.h"

@implementation UIView (TransitioningUtils)

- (UIImage*)blurScreenShot:(CGFloat)blurRadius {
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.frame.size.width, self.frame.size.height), false, 1);
    
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    CIFilter *blur = [CIFilter filterWithName:@"CIGaussianBlur"];
    
    [blur setValue:[[CIImage alloc] initWithImage:image] forKey:kCIInputImageKey];
    [blur setValue:[NSNumber numberWithFloat:blurRadius] forKey:kCIInputRadiusKey];
    
    CIContext *ciContext = [[CIContext alloc] init];
    CIImage *result = [blur valueForKey:kCIOutputImageKey];
    CGRect boundingRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    
    CGImageRef cgImage = [ciContext createCGImage:result fromRect:boundingRect];
    
    return [UIImage imageWithCGImage:cgImage];
    
}

- (void)maskFrom:(CGRect)fromRect duration:(NSTimeInterval)duration complete:(void(^)(void))complete {
    
}

- (void)maskTo:(CGRect)toRect duration:(NSTimeInterval)duration complete:(void(^)(void))complete {
    
}

@end
